package cn.monkey.transport.mq.redisson;


import cn.monkey.transport.core.Exchange;
import org.redisson.api.RedissonClient;

public abstract class AbstractRedissonExchangeFactory<EXCHANGE extends RedissonExchange> implements RedissonExchangeFactory<EXCHANGE> {
    protected final RedissonClient inboundClient;
    protected final RedissonClient outBoundClient;
    public AbstractRedissonExchangeFactory(RedissonClient redissonClient) {
        this(redissonClient, redissonClient);
    }

    public AbstractRedissonExchangeFactory(RedissonClient inboundClient, RedissonClient outBoundClient) {
        this.inboundClient = inboundClient;
        this.outBoundClient = outBoundClient;
    }

    protected abstract RedissonInbound newInbound(String key, RedissonTransportConfig.Inbound inbound);

    protected abstract RedissonOutbound newOutbound(String key, RedissonTransportConfig.Outbound outbound);

    @SuppressWarnings("unchecked")
    protected EXCHANGE inverse(EXCHANGE exchange) {
        return (EXCHANGE) exchange.inverse();
    }

    @Override
    public abstract EXCHANGE apply(String key, Exchange exchange, RedissonTransportConfig redissonTransportConfig);
}
